<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div {
        position: absolute;
        left: 0;
        width: 100px;
        height: 100px;
        background-color: pink;
    }
    
    span {
        position: absolute;
        left: 0;
        top: 200px;
        display: block;
        width: 150px;
        height: 150px;
        background-color: skyblue;
        text-align: center;
        line-height: 150px;
    }
</style>

<body>
    <div></div>
    <span>景玉龙</span>
    <script>
        var div = document.querySelector('div');
        var span = document.querySelector('span');

        function animate(obj, target) {
            var timer = setInterval(function() {
                if (obj.offsetLeft >= target) {
                    clearInterval(timer);
                }
                obj.style.left = obj.offsetLeft + 2 + 'px';
            }, 30);
        }
        animate(div, 300);
        animate(span, 300);
    </script>
</body>

</html>